/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view;
import dao.*;
import pojo.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import plugin.DatePicker;
/**
 *
 * @author QTuan
 */
public class Menu extends javax.swing.JFrame {

    /**
     * Creates new form Menu
     */
    private PersonnelDetail account;
    public Menu(String personnel) {
        initComponents();
        personnel = "admin";
        DAOPersonnel daoPersonnel = new DAOPersonnel();
        
        PersonnelDetail detailAccount = daoPersonnel.getDetailAccount(personnel);
        this.account = detailAccount;
        this.lbTenNhanVien.setText(this.account.getName());
        if(detailAccount.getRole().equals("admin"))
        {
            this.jTabbedPane1.addTab("Nhập hàng vào kho", new NhapKho(this.account,personnel));
            this.jTabbedPane1.addTab("Xuất hàng khỏi kho", new XuatKho(this.account,personnel));
            //this.jTabbedPane1.addTab("Xuất hàng khỏi kho", new XuatHangKho(this.account,personnel));
            this.jTabbedPane1.addTab("Quản lí khuyến mãi", new QuanLyKhuyenMai());
            this.jTabbedPane1.addTab("Quản lí khách hàng", new QuanLyKhachHang());
            this.jTabbedPane1.addTab("Quản lí Quy định", new ThayDoiQuyDinh());
            this.jTabbedPane1.addTab("Bán hàng tại cửa hàng", new BanHang(account, personnel));
            this.jTabbedPane1.addTab("Report", new Report(account));
        }else
        {
            if(detailAccount.getRole().equals("Quản lí"))
            {
                this.jTabbedPane1.addTab("Nhập hàng vào kho", new NhapKho(this.account,personnel));
                this.jTabbedPane1.addTab("Xuất hàng khỏi kho", new XuatKho(this.account,personnel));
            }else
            {
                this.jTabbedPane1.addTab("Danh mục sản phẩm", new DanhMucSanPham());
                this.jTabbedPane1.addTab("Quản lí khuyến mãi", new QuanLyKhuyenMai());
                this.jTabbedPane1.addTab("Quản lí khách hàng", new QuanLyKhachHang());
                this.jTabbedPane1.addTab("Quản lí Quy định", new ThayDoiQuyDinh());
            }
        }
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        lbTenNhanVien = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Nhan Vien:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(35, 35, 35)
                        .addComponent(lbTenNhanVien)
                        .addGap(0, 1028, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lbTenNhanVien))
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 617, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Menu("").setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lbTenNhanVien;
    // End of variables declaration//GEN-END:variables
}
